<?php
namespace Cms\Widget;
use Think\Controller;

/**
 * Class DashboardWidget
 * @package Cms\Widget
 * @author:赵俊峰 981248356@qq.com
 */
class DashboardWidget extends Controller
{
    /**
     * cmstool  CMS工具条
     * @author:赵俊峰 981248356@qq.com
     */
    public function cmstool()
    {
        $generalize=$info=array();
        //概括
        $generalize['usercount']=M('Users')->where(array('uid'=>array('gt',0)))->count('uid');//用户数
        $generalize['postcount']=M('Posts')->where("type='%s'",'post')->count('id');//文章数
        $generalize['pagecount']=M('Posts')->where("type='%s'",'page')->count('id');//页面数
        $generalize['commentcount']=M('Comments')->count('id');//页面数
            
        $this->assign('generalize', $generalize);    
        $this->display(T('Cms@AdminCms/WidgetCmstool'));
    }
    /**
     *   Latest posts
     * @author:赵俊峰 981248356@qq.com
     */
    public function latestList()
    {
        // 获取所有文章
        $map['status'] = array('egt', '0'); // 禁用和正常状态
        $map['type']='post';
        $paged=I('get.p/d',1);
        list($post_list,$totalCount) = D('Cms/posts')->getListByPage($map,$paged,'create_time desc','id,title,create_time',6);
        $this->assign('post_list', $post_list);    
        $this->display(T('Cms@AdminCms/WidgetLatestList'));
    }

}